package com.ideal.frame.util;

import com.ideal.frame.sys.dto.UserDto;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * @Author: jin
 * @CreateTime: 2020-02-25 13:36
 * @Description: 获取用户信息工具类
 */
public class UserUtils {
    public static Authentication getCurrentUserAuthentication(){
        return SecurityContextHolder.getContext().getAuthentication();
    }

    public static UserDto getCurrentUser(){
        return (UserDto)getCurrentUserAuthentication().getPrincipal();
    }
}
